package model.security;

import model.configuration.ConfigData;

import org.simpleframework.xml.*;

@Root(name = "applicationuser")
public class ApplicationUser {
	
	@Attribute(name = "id")
	long id = ConfigData.NOVALUELONG; // object id in database
	
	@Element(name = "login")
	String login; // user login name
	
	@Element(name = "firstname")
	String firstName; // user first name
	
	@Element(name = "secondname")
	String secondName;// user second name
	
	boolean passAuthentication = false; // Did user has already passed authentication

	/**
	 * Return user login
	 * @return
	 */
	public String getLogin() {
		return login;
	}

	/**
	 * Set user login
	 * @param login
	 */
	public void setLogin(String login) {
		this.login = login;
	}

	/**
	 * Return user first name
	 * @return
	 */
	public String getFirstName() {
		return firstName;
	}

	/**
	 * Set user first name
	 * @param firstName
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	/**
	 * return user second name
	 * @return
	 */
	public String getSecondName() {
		return secondName;
	}

	/**
	 * set user second name
	 * @param secondName
	 */
	public void setSecondName(String secondName) {
		this.secondName = secondName;
	}

	/**
	 * True if  authentication pass
	 * @return
	 */
	public boolean isPassAuthentication() {
		return passAuthentication;
	}
	
	/**
	 * Return id in object
	 * @return
	 */
	public long getId() {
		return id;
	}
	
	/**
	 * Return true if authentication will passed
	 * @param userLogin
	 * @param userPassword
	 * @return
	 */
	public boolean passAuthentication(String userLogin, String userPassword) {

		/* before data will get from database this code will pass authentication {*/
		String loginList[] = {"user1", "user2", "user3"};
		String passList[] = {"pass1", "pass2", "pass3"};
		
		for(int i = 0; i<=loginList.length; i++) {
			if (userLogin.equalsIgnoreCase(loginList[i]) && userPassword.equals(passList[i])) {
				passAuthentication = true;
			}
			else {
				passAuthentication = false;
			}
		}
		/*} before data will get from database this code will pass authentication */
		
		
		return passAuthentication;
	}
	
	
	
}
